//
//  UserViewController.m
//  项目
//
//  Created by 张诗雨 on 14/12/29.
//  Copyright (c) 2014年 张诗雨. All rights reserved.
//

#import "UserViewController.h"
#import "WebColor.h"
#import "UserTableViewCell.h"
#import "LoginViewController.h"
@interface UserViewController ()

@end

@implementation UserViewController
- (void)dealloc
{
    [super dealloc];
}
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [WebColor whiteSmoke];
    [self createView];
}
- (void)createView
{
    UITableView *tableView = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStyleGrouped];
    tableView.delegate = self;
    tableView.dataSource = self;
    [tableView registerClass:[UserTableViewCell class] forCellReuseIdentifier:@"cell"];
    tableView.backgroundColor = [WebColor whiteSmoke];
    [self.view addSubview:tableView];
    [tableView release];
}
/// tableView的点击时间触发方法
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        
        LoginViewController *loginVC = [[LoginViewController alloc] init];
        [self presentViewController:loginVC animated:YES completion:^{
            
        }];
        [loginVC release];
    }
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UserTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    if (indexPath.section == 0) {
        cell.imgView.image = [UIImage imageNamed:@"user_right.png"];
        cell.lable.text = @"立即登录";
    }
    if (indexPath.section == 1) {
        cell.imgView.image = [UIImage imageNamed:@"user_down.png"];
        cell.lable.text = @"我的下载";

    }
    return cell;
}
/// row的行高
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 30;
}
/// section number
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
